﻿using MtApi;
using MTEA.LIB;
using MTEA.LIB.Analysis.KDJ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MTEA.UI
{
    /// <summary>
    /// KDJTaskControl.xaml 的交互逻辑
    /// </summary>
    public partial class KDJTaskControl : UserControl
    {
        public KDJTaskControl()
        {
            InitializeComponent();
            timeFramesComboBox.ItemsSource = System.Enum.GetNames(typeof(ENUM_TIMEFRAMES));
            OrderTypeComboBox.ItemsSource = System.Enum.GetNames(typeof(OrderType));
            KDJCrossTypeComboBox.ItemsSource = System.Enum.GetNames(typeof(KDJCrossType));

            timeFramesComboBox.SelectedIndex = 0;
            OrderTypeComboBox.SelectedIndex = 0;
            KDJCrossTypeComboBox.SelectedIndex = 0;

        }

        private void confirmBtn_Click(object sender, RoutedEventArgs e)
        {
            int timeFrames = (int)System.Enum.Parse(typeof(ENUM_TIMEFRAMES), timeFramesComboBox.SelectedItem.ToString());
            double lots = double.Parse(lotsTxt.Text);
            int orderType = (int)System.Enum.Parse(typeof(OrderType), OrderTypeComboBox.SelectedItem.ToString());
            int kdjCrossType = (int)System.Enum.Parse(typeof(KDJCrossType), KDJCrossTypeComboBox.SelectedItem.ToString());
            int shift= int.Parse(shiftTxt.Text);
            int kdjType = int.Parse(kdjTypeTxt.Text);
            double maxValue = double.Parse(maxValueTxt.Text);
            double minValue = double.Parse(minValueTxt.Text);
            string result = string.Empty;
            if (orderType == (int)OrderType.Close)
            {
                result = string.Format("closekdj {0} {1} {2} {3} {4} {5} {6}", timeFrames, lots, shift, kdjType, kdjCrossType, maxValue, minValue);
            }
            else
            {
                result = string.Format("addbollingtask {0} {1} {2} {3} {4} {5} {6} {7}", timeFrames, lots, orderType, shift, kdjType,kdjCrossType,maxValue,minValue);
            }
            resultTxtBlock.Text = result;
            Clipboard.SetDataObject(result);
        }
    }
}
